package ev;

import java.util.*;
import ev.*;
import ev.data.*;
import ev.operator.*;
import ev.selection.*;

public class GaInverover implements Assignment1{
	private int limit = 10000;//terminating condition

	public GaInverover() {
	}
	
	public void emulation() {
		ArrayList<City> cities=MyData.getCityData();//get city data from static method
		Population initialPopulation = new Population(cities);
		Individual best = null;
		InverOver inver = new InverOver();
		
		int populationsize = 50;//population size set here
		
		for(int i=0; i<populationsize; i++)
		{
			initialPopulation.add(new Individual(cities.size()));
		}
		int count = limit;
		while(count > 0) {
			count--;
			initialPopulation = inver.inverover(initialPopulation);
			System.out.println(count);
		}
		best = initialPopulation.getIndividual(0);
		for(int i=1; i<populationsize; i++){
			if(best.getQuality() > initialPopulation.getIndividual(i).getQuality()){
				best = initialPopulation.getIndividual(i);
			}
		}
		System.out.println("Best="+best.getQuality());
	}
	
}
